#pragma once

#include "CProcessBase.h"
#include "CArmatureAniData.h"
#include "CTween.h"
#include "CBone.h"

class CCArmature;


static const char* START = "start";

static const char* COMPLETE = "complete";

static const char* LOOP_COMPLETE = "loopComplete";

static const char* IN_FRAME = "inFrame";


class CCAnimationEventListener{
public:
	virtual void animationHandler(const char* _aniType, const char* _aniID, const char* _frameID) = 0;
};



class CCArmatureAnimation : public CCProcessBase
{
public:
    static CCArmatureAnimation *create();
public:
    CCArmatureAnimation();
    ~CCArmatureAnimation(void);

    virtual bool init();

    
    void remove();
    void pause();
    void resume();
    void stop();
    
    CCArmatureAniData* getData();
    void setData(CCArmatureAniData* _aniData);
    
    void setAnimationScale(float _scale, const char* _boneName = "");
    
    void addTween(CCBone* _bone);
   
    void removeTween(CCBone* _bone);
    
    CCTween *getTween(const char* _boneID);
    
    void updateTween(const char *_boneID, float dt);
    
    void playTo(void * _to, int _durationTo = -1, int _durationTween = -1,  bool _loop = true, int _ease = -2);

    void updateHandler();

    void updateCurrentPrecent();
public:
    
	CC_SYNTHESIZE(CCAnimationEventListener *, mEventListener, AniEventListener);

protected:
    CCArmatureAniData	*mArmatureAniData;
    CCBoneAniData		*mBoneAniData;
	
private:
	
    // <const char*, CCTween*>
    CCDictionary	*mTweens;
	
    const char*		mAniIDNow;

};

